<template>
  <div class="search-input-wrap">
    <div class="search-input">
      <span class="iconfont icon-header-search"></span>
      <input ref="hint" id="hint" type="text" :placeholder="hint" @input="onSearchChenge" />
    </div>
  </div>
</template>

<script>
  import tools from '@/utils/tools.js';

  export default {
    name: 'SearchInput',
    data: function() {
      return {
        hint: '美食 / 景点 / 酒店 / 按摩 / KTV',
      }
    },
    methods: {
      onSearchChenge: tools.throttle(function() {
        var iptValue = this.$refs.hint.value,
          val = tools.trimSpace(iptValue);
        this.$emit('searchChenge', val);
      }, 1000),
    }
  }
</script>

<style lang="scss" scoped="scoped">
  .search-input-wrap {
    position: fixed;
    top: .5rem;
    z-index: 99;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: .44rem;
    background-color: #FFFFFF;

    .search-input {
      display: flex;
      flex-direction: row;
      justify-content: center;
      align-items: center;
      width: 90%;
      border: 1px solid #CCCCCC;
      border-radius: .03rem;
      overflow: hidden;
      box-sizing: border-box;

      span {
        padding: 0 .1rem;
        box-sizing: border-box;
        text-align: center;
      }

      #hint {
        height: .3rem;
        width: 100%;
        flex: 1;
        font-size: .14rem;
      }
    }


  }
</style>
